# -*- coding: utf-8 -*-


"""
建造者模式

模式特点：将一个复杂对象的构建(Director)与它的表示(Builder)分离，使得同样的构建过程可以创建不同的表示(ConcreteBuilder)。

程序实例：“画”出一个四肢健全（头身手腿）的小人

代码特点：无
"""


class Person(object):

    def create_head(self):
        pass

    def create_hand(self):
        pass

    def create_body(self):
        pass

    def create_foot(self):
        pass


class ThinPerson(Person):

    def create_head(self):
        print "thin head"

    def create_hand(self):
        print "thin hand"

    def create_body(self):
        print "thin body"

    def create_foot(self):
        print "thin foot"


class ThickPerson(Person):
    def create_head(self):
        print "thick head"

    def create_hand(self):
        print "thick hand"

    def create_body(self):
        print "thick body"

    def create_foot(self):
        print "thick foot"


class Director:
    def __init__(self, temp):
        self.p = temp

    def create(self):
        self.p.CreateHead()
        self.p.CreateBody()
        self.p.CreateHand()
        self.p.CreateFoot()

if __name__ == "__main__":
    p = ThickPerson()
    d = Director(p)
    d.create()
